home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / arrays.exe / ARRAYS.INF < prev    next >
Text File  |  1991-11-02  |  3KB  |  55 lines

  1. ARRAYS.INF                                                         dh:91-11-02
  2.  
  3.                    DEMONSTRATION OF POINTERS TO ARRAYS
  4.                    -----------------------------------
  5.  
  6. The use of pointers to arrays is a baffling problem in C and C++ because
  7. the C Language doesn't have any first-class notion of arrays.  This can lead
  8. to mysterious compiler complaints and execution behavior because the user's
  9. conventional model of what arrays and the naming of arrays is about is
  10. actually not supported directly in C Language.  Arrays as other programming
  11. languages may support them are actually obtained mainly by subterfuge in
  12. C Language.  The subterfuge is an extremely useful one until the programmer
  13. is thrown up against a serious dissonance between intuitive assumptions and
  14. what the C Language rules *really* are.
  15.  
  16. The two sample programs in this package provide simple demonstration of
  17. one such area of dissonance -- trying to initialize and use a properly-defined
  18. pointer to an array without getting error messages and possibly incorrect
  19. behavior.
  20.  
  21. There are two modules: ARRAYS.C and ARRAYS.CPP.  The first is in C Language,
  22. the second is in C++ Version 2.0.  They should be compiled separately for what
  23. they reveal about arrays and pointers to arrays as usable objects (e.g., as
  24. lvalues and rvalues as C Cognoscenti are prone to say).
  25.  
  26. For those who enjoy the Borland C++ 2.0 interactive environment, there is
  27. an arrays.prj file that you can use to help with this.  If you compile these
  28. files from something like
  29.  
  30.     C:>BC ARRAYS>PRJ
  31.  
  32. remember to go into the Options/Directory pull-down and correct the location
  33. of libraries and include files to agree with your configuration setup.
  34.  
  35. These two little files were composed as the result of head-banging that
  36. colleagues Barry Gombert, Bill Anderson and I went through trying to get
  37. some array-pointing code to come out clean.  If you stare at this and the
  38. inscrutible error messages that go with it, maybe your head won't hurt so
  39. much the next time you try to get array references to come out right!
  40.  
  41.                                             -- Dennis E. Hamilton
  42.                                                1991 November 2
  43.  
  44.                                                orcmid.roch817@xerox.com
  45.                                                70100.271@compuserve.com
  46.  
  47.  
  48. CONTENTS:
  49.  
  50.     ARRAYS   C       1225  10-29-91  1:09p 1.00 ANSI C array-pointing behavior
  51.     ARRAYS   CPP     1575  10-29-91  1:30p 1.01 C++ 2.0 array-pointing behavior
  52.     ARRAYS   DES      331  11-02-91  4:12p NDOS descriptions for ARRAYS package
  53.     ARRAYS   DSK     2489  10-29-91  7:15p Borland C++ Desktop for IDE use
  54.     ARRAYS   PRJ     5316  10-29-91  7:15p Borland C++ Project for ARRAYS exploring
  55.